export function findBaseUrlFromEnv(envMap: Record<string, string> = {}, envFields: string | string[]): string[] {
  const temp: string[] = []
  for (const [key, val] of Object.entries(envMap)) {
    if (Array.isArray(envFields)) {
      if (envFields.includes(key)) {
        temp.push(val as string)
      }
    }
    else {
      if (key.includes(envFields)) {
        return [val as string]
      }
    }
  }
  return temp
}
/**
 * @description 将url 转换为 路径安全的字符串
 * @param url
 * @returns
 */
export function urlToProxyPath(url: string): string {
  if (!url) return ''
  // 将url不安全字符转为安全路径
  return url.replace(/^https?:\/\//, '').replace(/[\\/:*?"<>|\r\n.]+/g, '_').replace(/^\.{2,}|\.+$/g, '')
}
